package com.uinnova.product.eam.init.schedule;

import com.binary.framework.bean.annotation.Comment;
import com.uinnova.product.eam.init.schedule.job.CyAutoCreateJob;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Comment("自动创建系统文件夹定时任务配置")
@Configuration
public class CyAutoCreateQuartzConfiguration {

    @Value("${category.auto.create.cron:0 0/10 * * * ?}")
    private String cyAutoCreateCron;

    @Bean
    public JobDetail cyAutoCreateJob() {
        return JobBuilder.newJob(CyAutoCreateJob.class).withIdentity("CyAutoCreateJob").storeDurably().build();
    }

    @Bean
    public Trigger cyAutoCreateJobTrigger(JobDetail cyAutoCreateJob) {
        CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(cyAutoCreateCron);
        return TriggerBuilder.newTrigger().forJob(cyAutoCreateJob)
                .withIdentity("CyAutoCreateJob").withSchedule(scheduleBuilder).build();
    }

}
